<?php
require_once 'App/UserService.php';
require_once 'Zend/Controller/Action.php';

class UserController extends Zend_Controller_Action
{
	protected $userService;
	
	public function preDispatch()
	{
		$this->userService = new App_UserService();
		$layout = Zend_Layout::getMvcInstance();
		$layout->message = '';
		$this->session = new Zend_Session_Namespace('default');
	}
	
	public function indexAction()
	{
		
	}
	
	public function addAction()
	{
		$form = new App_Forms_UserForm();
		
		if ($this->_request->isPost()) 
    	{
    		$postData = $this->getRequest()->getPost();
    		$this->userService->saveUser($postData['Username'], 
    						$postData['Password'],
    						$postData['Firstname'],
    						$postData['Lastname'],
    						$postData['Email']);
    		$this->session->userID = $this->userService->lastID;
    		$this->_redirect('album');
    	}
    	$this->view->form = $form;
	}
}